\documentclass{article}
\usepackage{geometry}
\geometry{margin=1.5cm, vmargin={0pt,1cm}}
\setlength{\topmargin}{-1cm}
\setlength{\paperheight}{29.7cm}
\setlength{\textheight}{25.3cm}

% useful packages.
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{enumerate}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{fancyhdr}
\usepackage{layout}
% \usepackage{ctex}
\usepackage{listings}
\usepackage{subfigure}
\usepackage{setspace}

% some common command
\newcommand{\dif}{\mathrm{d}}
\newcommand{\avg}[1]{\left\langle #1 \right\rangle}
\newcommand{\difFrac}[2]{\frac{\dif #1}{\dif #2}}
\newcommand{\pdfFrac}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\OFL}{\mathrm{OFL}}
\newcommand{\UFL}{\mathrm{UFL}}
\newcommand{\fl}{\mathrm{fl}}
\newcommand{\op}{\odot}
\newcommand{\Eabs}{E_{\mathrm{abs}}}
\newcommand{\Erel}{E_{\mathrm{rel}}}
\newcommand{\RNum}[1]{\uppercase\expandafter{\romannumeral #1\relax}}

\usepackage{xcolor}
\usepackage{fontspec} 
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{comment}{rgb}{0.56,0.64,0.68}

\newfontfamily\monaco{Monaco}
\lstset {
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,       % underline spaces within strings
columns=flexible,
framerule=1pt,
rulecolor=\color{gray!35},
backgroundcolor=\color{gray!5},
basicstyle={\small\monaco},           % the size of the fonts that are used for the code
numbers=left,                   % where to put the line-numbers
numberstyle=\tiny\monaco\color{gray},  % the style that is used for the line-numbers
numbersep=5pt,                  % how far the line-numbers are from the code
commentstyle=\color{comment},
keywordstyle=\color{blue},
stringstyle=\color{dkgreen},
tabsize=2,                      % sets default tabsize to 2 spaces
captionpos=b,                   % sets the caption-position to bottom
breaklines=true,                % sets automatic line breaking
breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
escapeinside={\%*}{*)},            % if add LaTeX within your code
morekeywords={*,...}               % if add more keywords to the set
}


\begin{document}
\title{Homework \#2}
\pagestyle{fancy}
\lhead{Name Li HuiTeng 3180102114}
\chead{ NumAnalysis\#2}
\rhead{Date 21.10.19}

\section{Theoretical questions}
This part can be found in Latex Folder.

\section{C++ programming}
Use $ \textbf{make all} $ to generate all answers! \\ 
Codes are contained in the e-mail tar, and only conclusions will be shown in the following part.\\
Results are shown below, generating from $ \textbf{make run} $.
\lstset{language=Matlab}
\begin{lstlisting}
  g++ -o Assignment.o Assignment.cpp
  ./Assignment.o
  -----------------------Assignment B-----------------------
  px = -0.0384615*x.^2 +1*x.^0 
  px = 0.00530504*x.^4 -0.171088*x.^2 +1*x.^0 
  px = -0.000840633*x.^6 +0.0335319*x.^4 -0.351364*x.^2 +1*x.^0 
  px = 0.000137445*x.^8 -0.00658016*x.^6 +0.0981875*x.^4 -0.528121*x.^2 +1*x.^0 
  Generate AssignmentB.m!
  -----------------------Assignment C-----------------------
  px = 2.7465*x.^4 -3.54298*x.^2 +1*x.^0 
  px = 5.51277*x.^8 -14.0024*x.^6 +12.6193*x.^4 -4.81162*x.^2 +0.730822*x.^0 
  px = -333.619*x.^14 +1264.42*x.^12 -1927.18*x.^10 +1510.61*x.^8 -646.864*x.^6 +149.027*x.^4 -17.3641*x.^2 +1*x.^0 
  px = -788.326*x.^18 +3973.16*x.^16 -8534.89*x.^14 +10195.5*x.^12 -7413.45*x.^10 +3379.02*x.^8 -960.825*x.^6 +165.458*x.^4 -16.5422*x.^2 +0.96241*x.^0 
  Generate AssignmentC.m!
  -----------------------Assignment D-----------------------
  px = -2.02236e-05*x.^9 +0.00104059*x.^8 -0.0218757*x.^7 +0.243041*x.^6 -1.5383*x.^5 +5.50812*x.^4 -10.0953*x.^3 +7.16191*x.^2 +75*x.^1 
  The derivation of px = -0.000182013*x.^8 +0.00832472*x.^7 -0.15313*x.^6 +1.45825*x.^5 -7.69148*x.^4 +22.0325*x.^3 -30.2859*x.^2 +14.3238*x.^1 +75*x.^0 
  (a) When t = 10, 
  Position: 742.503 feet from Time 0.
  Speed: 48.3817 feet per second.
  (b) For t from 0 to 13, 
  the car exceeds the speed limit when t = 5.93 .
  -----------------------Assignment E-----------------------
  px = 4.1477e-05*x.^6 -0.00371557*x.^5 +0.128281*x.^4 -2.11512*x.^3 +16.2855*x.^2 -43.0127*x.^1 +6.67*x.^0 
  px = 8.6768e-06*x.^6 -0.000777473*x.^5 +0.0265858*x.^4 -0.424283*x.^3 +2.98227*x.^2 -5.85018*x.^1 +6.67*x.^0 
  Generate AssignmentE.m !  
\end{lstlisting}

For AssignmentE, we can see from plotting that both two samples of larvae will survive after 15 days.

Picture results are shown below, generating from $ \textbf{make plot} $.
\newpage
\includegraphics[width=0.8\textwidth]{AssignmentB.png}

\includegraphics[width=0.8\textwidth]{AssignmentC.png}

\includegraphics[width=0.8\textwidth]{AssignmentE1.png}

\includegraphics[width=0.8\textwidth]{AssignmentE2.png}


\end{document}
%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 
